<?php
/**
 * A simple description for this script
 *
 * PHP Version 5.2.0 or Upper version
 *
 * @package    Paylog
 * @author     Hidehito NOZAWA aka Suin <http://suin.asia>
 * @copyright  2010 Hidehito NOZAWA
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
 *
 */

abstract class Paylog_Abstract_FormController extends Paylog_Abstract_Controller
{
	protected $input  = null;
	protected $errors = array();

	public function main()
	{
		try
		{
			if ( isset($_POST['preview']) )
			{
				$this->_get();
				$this->_validate();
				$this->_preview();
				$this->_form();
			}
			elseif ( isset($_POST['save']) )
			{
				$this->_get();
				$this->_validate();
				$this->_save();
				die;
			}
			elseif ( isset($_POST['delete']) )
			{
				$this->_load();
				$this->_delete();
				die;
			}
			else
			{
				$this->_load();
				$this->_form();
			}
		}
		catch( Exception $e )
		{
			$this->_form();
		}
	}

	abstract protected function _load();

	abstract protected function _get();

	abstract protected function _validate();

	abstract protected function _preview();

	abstract protected function _save();

	abstract protected function _delete();

	abstract protected function _form();
}

?>
